# 保存每个月的天数
ls = [31,28,31,30,31,30,31,31,30,31,30,31]

year = int(input("年:"))
month = int(input("月:"))
day = int(input("日"))

# 判断是否是闰年
if year%400==0 or (year%100!=0 and year%4==0):
    ls[1] +=1

# 把前面的月份都加上
result=0
for i in range(0,month-1):
    result += ls[i]

# 加上本月天数
result += day

print(result)























    